<template>
  <div>
    <!--面包屑导航区域-->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>用户管理</el-breadcrumb-item>
      <el-breadcrumb-item>用户进出管理</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card>
      <!--           搜索框添加按钮-->
      <el-row :gutter="20">
        <el-col :span="8">
          <el-input placeholder="请输入内容"
                    v-model="queryInfo.query"
                    clearable
                    @clear="getUserList">
            <el-button slot="append" icon="el-icon-search" @click="getUserList"></el-button>
          </el-input>
        </el-col>
      </el-row>
      <!--客户列表区域  -->
      <el-table v-loading="loading"
                :data="userList"
                border
                height="490"
                stripe>
        <el-table-column label="#" type="index"></el-table-column>
        <el-table-column label="用户名" prop="username" width="200px"></el-table-column>
        <el-table-column label="用户姓名" prop="name" width="200px"></el-table-column>
        <el-table-column label="用户角色" prop="roleName"></el-table-column>
        <el-table-column label="用户体温" prop="humtem" sortable></el-table-column>
        <el-table-column label="联系方式" prop="phone"></el-table-column>
        <el-table-column label="进馆时间" prop="entertime" sortable></el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      //根据姓名查询
      queryInfo: {
        query: ''
      },

      //表格数据
      userList: []
    }
  },
  methods: {
    //查看客户订单
    async getUserList() {
      this.loading = true
      let _this = this,
          curr_user = this.$store.state.user.name;
      let rolename = this.$store.state.user.roleName;
      console.log(rolename);
      if (rolename == '系统管理员' || rolename == '超级管理员') {
        console.log("管理员专属通道")
        const res = await this.$http.get('/employee/allusermanager/')
        console.log(res)
        if (!res) return;
        if (res) {
          this.userList = res.obj;
        }
      } else {
        const res = await this.$http.get('/employee/usermanager/', {params: this.queryInfo})
        console.log(res)
        if (!res) return;
        if (res) {
          this.userList = res.obj;
        }
      }
      this.loading = false
    }

  },
  created() {
    this.getUserList();
  }
}
</script>

<style scoped>


</style>
